package com.qh.xx;

import com.qh.xx.list.LinkedList;
import com.qh.xx.list.List;

/**
 * @description:
 * @author: zqh
 * @date: 2021/11/5 12:32
 **/
public class Deque<E> {
    private List<E> list = new LinkedList<>();

    public int size(){
        return list.size();
    }

    public boolean isEmpty(){
        return list.isEmpty();
    }

    /**
     * 尾部入队
     * @param element
     */
    public void enQueueRear(E element){
        list.add(element);
    }

    /**
     * 头部出队
     * @param
     */
    public E deQueueFront(){
        return list.remove(0);
    }

    /**
     * 头部入队
     * @param element
     */
    public void enQueueFront(E element){
        list.add(0, element);
    }

    /**
     * 尾部出队
     * @param
     */
    public E deQueueRear(){
        return list.remove(list.size() - 1);
    }


    public E front(){
        return list.get(0);
    }

    public E rear(){
        return list.get(list.size() - 1);
    }

}
